package co.yixiang.yshop.module.tables.dal.mysql.table;

import java.util.*;

import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
import co.yixiang.yshop.module.tables.dal.dataobject.table.TableInfoDO;
import org.apache.ibatis.annotations.Mapper;
import co.yixiang.yshop.module.tables.controller.admin.table.vo.*;

/**
 * 餐桌 Mapper
 *
 * @author yshop
 */
@Mapper
public interface TableInfoMapper extends BaseMapperX<TableInfoDO> {

    default PageResult<TableInfoDO> selectPage(TableInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TableInfoDO>()
                .likeIfPresent(TableInfoDO::getTableName, reqVO.getTableName())
                .eqIfPresent(TableInfoDO::getTableType, reqVO.getTableType())
                .eqIfPresent(TableInfoDO::getTableCapacity, reqVO.getTableCapacity())
                .eqIfPresent(TableInfoDO::getTableLocation, reqVO.getTableLocation())
                .eqIfPresent(TableInfoDO::getTableStatus, reqVO.getTableStatus())
                .eqIfPresent(TableInfoDO::getActiveQrcode, reqVO.getActiveQrcode())
                .eqIfPresent(TableInfoDO::getReservationId, reqVO.getReservationId())
                .eqIfPresent(TableInfoDO::getTableNotes, reqVO.getTableNotes())
                .betweenIfPresent(TableInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TableInfoDO::getId));
    }

    default List<TableInfoDO> selectList(TableInfoExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TableInfoDO>()
                .likeIfPresent(TableInfoDO::getTableName, reqVO.getTableName())
                .eqIfPresent(TableInfoDO::getTableType, reqVO.getTableType())
                .eqIfPresent(TableInfoDO::getTableCapacity, reqVO.getTableCapacity())
                .eqIfPresent(TableInfoDO::getTableLocation, reqVO.getTableLocation())
                .eqIfPresent(TableInfoDO::getTableStatus, reqVO.getTableStatus())
                .eqIfPresent(TableInfoDO::getActiveQrcode, reqVO.getActiveQrcode())
                .eqIfPresent(TableInfoDO::getReservationId, reqVO.getReservationId())
                .eqIfPresent(TableInfoDO::getTableNotes, reqVO.getTableNotes())
                .betweenIfPresent(TableInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TableInfoDO::getId));
    }

}
